Repository navigation
⚡ Bolt: starter facts read two columns of the music window, not 4000 ORM rows - #376
Open
Randomname653 wants to merge 1 commit into
Open
Randomname653 wants to merge 1 commit into
Randomname653 wants to merge 1 commit into
Conversation
…ORM rows Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014GBDVAVCx4R54nee19m7p4
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
chat_starters.collect_factsruns on every chat open (chips) and on every starter batch. Its 14-day music window (LIMIT 4000) hydrates fullWatchHistoryEntryORM rows although onlyseries_titleandviewed_atare used; the 200-row video window uses 7 columns of ~30.Measured on a temp DB with 384k music plays + 300 video plays (ANALYZE run), median of 9, same process, alternating order:
collect_facts: ~320–360 ms → ~280–290 ms (6 statements either way; rest is unrelated).Change
db.query(col, col)instead ofdb.query(WatchHistoryEntry)for the music and video windows. Same filters, sameLIMIT, same dicts built from the Row. The orphan filter (with_loader_criteria) still applies to column queries — the new test seeds an orphaned play and checks it stays hidden.Measured effect / proof
See Problem. Window query roughly 2–4x faster and no ORM instances (4200 per call before).
Tests
New
tests/test_starters_facts_columns.py: countsWatchHistoryEntryload events duringcollect_factsand checks facts (last watched, music rotation, orphan hidden).test_enrichment_status_perf.py, which also fails on untouched main in the sandbox (SQLite 3.45.1 plan) and passes in CI.Risk & edge cases
r.title,r.completed) is unchanged;bool(r.completed)still handles NULL.Duplicate check
Searched the journal, other personas' journals, PRs for
collect_facts, and the last 300 commits on main: nothing touches this.Generated by Claude Code